home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / rdir.arc / RDIR.ASM next >
Encoding:
Assembly Source File  |  1985-06-09  |  3.8 KB  |  159 lines

  1. ;RDIR.ASM    Rename Directory
  2. ;
  3. ;12.18.84    Zider Brothers, San Francisco (LSZ)
  4. ;
  5. ;Based on code modified from several sources:
  6. ;
  7. ;    ALIAS.ASM    Susan Glinert-Cole, version of 9.15.84
  8. ;            Creative Computing, January 1985, pp. 173-175
  9. ;    RENDIR.COM    Mike Flynn
  10. ;            Public domain program, version ? disassembly
  11. ;    MOVE.COM    From Windmill BBS (Terry Duke)
  12. ;            Public domain program, disassembly
  13. ;
  14. ;Usage:
  15. ;
  16. ;    A>RDIR [drive]oldname newname
  17. ;
  18. ;                    
  19. ;Function:
  20. ;
  21. ;    Rename a directory or a subdirectory.
  22. ;    
  23. ;Features:
  24. ;
  25. ;    On-line syntax help (when null command line tail).
  26. ;    Multi-drive OK, but no paths (current directories only).
  27. ;    Wildcard renaming OK.
  28. ;    Command line input check, error messages.
  29. ;    Error messages suppressed when syntax help is given.
  30. ;    Checks for DOS 2.0 or higher.
  31. ;
  32. ;Rationale:
  33. ;
  34. ;    DOS function REN operates on files only.
  35. ;    Glinert-Cole version has no on-line syntax help.  Some typos in
  36. ;      the published version.  Extra code stripped.  Apparently unaware 
  37. ;      that her version supports drives other than the default drive.
  38. ;    Flynn version requires prompted keyboard input (no command-line input),
  39. ;      and does not support drive specification (default drive only).
  40. ;
  41. ;
  42. ;Copyright 1984, Zider Brothers
  43. ;Released to the public domain for personal use only.  All rights reserved.
  44. ;
  45. ;
  46. RET_NEAR    MACRO
  47. DB    0C3H
  48.     ENDM
  49.  
  50. PRINT    MACRO    TEXT
  51.     MOV    DX,OFFSET TEXT        ;;shorter code than LEA
  52.     MOV    AH,09
  53.     INT    21H
  54.     ENDM
  55. ;
  56. CSEG    SEGMENT    PARA PUBLIC 'CODE'
  57. ;
  58.     ORG    100H
  59.     ASSUME    CS:CSEG, SS:CSEG
  60.     ASSUME    DS:CSEG, ES:CSEG
  61. ;
  62. START:    
  63. CK_DOS:    MOV    AH,30H
  64.     INT    21H
  65.     CMP    AL,2                
  66.     JNB    OK_DOS
  67.     MOV    DX,OFFSET WRONG_DOS_MSG        
  68.     MOV    AH,9
  69.     INT    21H
  70.     INT    20H
  71. WRONG_DOS_MSG    DB    'Incorrect DOS version.',CR,LF,'$'
  72. OK_DOS:
  73.     JMP    BEGIN
  74. ;
  75. CR    EQU    0DH
  76. LF    EQU    0AH
  77. TRUE    EQU    0FFH
  78. FALSE    EQU    NOT TRUE
  79. FCB    EQU    5CH
  80. EFCB    EQU    FCB-7
  81. ATTR    EQU    FCB-1
  82. OK_MSG    DB    'Renamed',CR,LF,'$'    
  83. ER_MSG    DB    'Directory not found.',CR,LF,'$'
  84. H_FLAG    DB    00
  85. ;
  86. BEGIN:    
  87.     CALL    INCHECK
  88.     CMP    H_FLAG,TRUE
  89.     JZ    EXIT
  90.     MOV    BX,EFCB            ;load Extended File Control Block..
  91.     MOV    BYTE PTR[BX], 0FFH    ;..with FF at FCB-7..
  92.     MOV    BX,ATTR            ;..and 10 for the directory attribute..
  93.     MOV    BYTE PTR[BX], 10H    ;..at FCB-1
  94. RENAME:
  95.     MOV    DX,EFCB            ;give DOS the beginning of the EFCB..
  96.     MOV    AH,17H            ;..and call to do the renaming
  97.     INT    21H
  98. STATUS_OUT:
  99.     CMP    AL,0FFH
  100.     JE    ERROR
  101.     PRINT    OK_MSG
  102. EXIT:    
  103.     RET
  104. ERROR:
  105.     PRINT    ER_MSG
  106.     RET
  107. ;
  108. INCHECK    PROC    NEAR
  109.  
  110.     MOV    H_FLAG,TRUE        ;set help flag on, assuming the worst
  111.     MOV    CL,DS:80H        ;set pointer to read the command line..
  112.     MOV    CH,0            ;..tail
  113.     CMP    BYTE PTR DS:80H,0    ;check for zero length cmd line tail
  114.     JZ    ON_LINE_SYNTAX        ;error if zero
  115.     MOV    DI,81H            ;Start scanning line,..
  116.     MOV    AL,20H    ;' '        ;..looking for leading blanks..
  117.     REPZ    SCASB            ;..and skipping them
  118.     JCXZ    ON_LINE_SYNTAX        ;but error if CX is zero on exit
  119.     REPNZ    SCASB            ;continue scan, now for non-blank..
  120.     JCXZ    INVALID_OPERANDS_ERROR    ;..and error if CX zero on exit
  121.     REPZ    SCASB            ;scan for blanks..
  122.     JCXZ    INVALID_NEW_NAME_ERROR    ;..error if exit before new name 
  123.     MOV    H_FLAG,FALSE
  124.     RET                ;OK input
  125.  
  126. INVALID_OPERANDS_ERROR:
  127.     MOV    DX,OFFSET INVALID_OPERANDS_MSG
  128.     MOV    AH,9
  129.     INT    21H
  130.     RET_NEAR
  131.  
  132. ON_LINE_SYNTAX:
  133.     MOV    DX,OFFSET SYNTAX_MSG
  134.     MOV    AH,9
  135.     INT    21H
  136.     RET_NEAR
  137.  
  138. INVALID_NEW_NAME_ERROR:
  139.     MOV    DX,OFFSET INVALID_NEW_NAME_MSG
  140.     MOV    AH,9
  141.     INT    21H
  142.     RET_NEAR
  143.  
  144. INVALID_OPERANDS_MSG    EQU    $
  145.     DB    'Invalid or missing operands',CR,LF,'$'
  146. INVALID_NEW_NAME_MSG    EQU    $
  147.     DB    'Invalid or missing new name',CR,LF,'$'
  148. SYNTAX_MSG        EQU    $    
  149.     DB    'Syntax: A>RDIR [drive]oldname newname',CR,LF
  150.     DB    CR,LF
  151.     DB    '               No path allowed.  Drive, wildcards OK.',CR,LF
  152. CRLF    DB    CR,LF,'$'
  153.  
  154. ;
  155. INCHECK    ENDP
  156. ;
  157. CSEG    ENDS
  158.     END    START
  159.